// interface operation
interface A {
    name: string,
    desc: string,
}

interface B {
    name: number,
    price: number,
}

type C = A | B; // name:string|number
type D = A & B; // name:never

// literal type operation
type T1 = 1 & 2; // never
type T2 = 'x' & true; // never
type H1 = 1 | 2;
type H2 = 'x' | true;

// basic type operation
type T3 = number & boolean; // never
type T4 = number & 1; // 1
type T5 = string & 'x'; // 'x'
type H3 = number | boolean;
type H4 = number | 1; // number
type H5 = string | 'x'; // string

// object type operation
type T6 = { x: number } & { x: string } // {x:never}
type T7 = { x: number } | { s: string } // {x:number|string}
type H6 = { x: number } | { x: string } // {x:number|string}
type H7 = { x: number } | { y: string }

// function type operation
type F1 = (a: number, b: string) => number | string;
type F2 = (a: string) => string;
type F3 = F1 & F2; // (a:number|string)=>string
const f: F3 = a => {
    console.log(a);
    return `${a}`;
}
f(1, 'test');
f('hello');

type F4 = (a: number) => number;
type F5 = (a: string, b: boolean) => object;
type F6 = F4 | F5; // (a:number)=>number;
const f2: F4 = a => {
    console.log(a);
    return a;
};
f2(1);

